package cn.com.roy.thread.t4_1_10.lockmethodtest1;

import java.util.concurrent.locks.ReentrantLock;

public class MyService {
    private ReentrantLock lock = new ReentrantLock();
    public void serviceMehod1(){
        try {
            lock.lock();
            System.out.println("service mthod1 getHoldCount=" + lock.getHoldCount()); //调用locked（）的次数
            serviceMthod2();
        } finally {
            lock.unlock();
        }

    }

    public void serviceMthod2(){

        try {
            lock.lock();
            System.out.println("service mthod2 getHoldCount=" + lock.getHoldCount()); //调用locked（）的次数
        } finally {
            lock.unlock();
        }
    }
}
